package com.zdd.chap4a.mapper;

import com.zdd.chap4a.entity.Book;
import com.zdd.chap4a.sql.SqlContext;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface BookMapper {
    //查询所有书
//    @Select("select * from book")
    public List<Book> findAllBooks();

    //动态查询书籍
//    @SelectProvider(method = "searchBookSql",type = SqlContext.class)
    public List<Book> searchBooks(Book book);

    //根据id号查找一本书
//    @Select("select * from book where id=#{id}")
    public Book findBookById(int id);

    //添加一本书
//    @Insert("insert into book values (0,#{name},#{price},#{category},#{pnum},#{imgurl},#{description},#{author},#{sales})")
    public void addBook(Book book);

    //修改一本书
//    @Update("update book set name=#{name},price=#{price},category=#{category},pnum=#{pnum},imgurl=#{imgurl},description=#{description},author=#{author},sales=#{sales} where id=#{id}")
    public void updateBook(Book book);

    //删除一本书
//    @Delete("delete from book where id=#{id}")
    public void deleteBook(int id);

    public void deleteBooks(int[] ids);
}
